package dev.alm.ggzxservice.utils;

import java.security.MessageDigest;

public class Md5Util {

    public static String encrypt(String input) throws Exception {
        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] bytes = input.getBytes();
        byte[] digest = md.digest(bytes);
        StringBuffer sb = new StringBuffer();
        for (byte b : digest) {
            sb.append(String.format("%02x", b & 0xff));
        }
        return sb.toString();
    }

    public static boolean decrypt(String input, String encrypted) throws Exception {
        return encrypt(input).equals(encrypted);
    }
}